<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 *  举报
 */
class Report extends Model
{
    protected $table = 'report';

    static function addRecord(
        $userId = 0,
        $reportedUserId = 0,
        $momentId = 0,
        $reason = '',
        $images = [],
        $desc = ''
    ) {
        $model = new self();
        $model->user_id = $userId;
        $model->reported_user_id = $reportedUserId;
        $model->moment_id = $momentId;
        $model->reason = $reason;
        $model->desc = $desc;
        $model->images = $images ? json_encode($images) : '';
        $model->flag = 1;
        return $model->saveOrFail() ? 1 : 0;
    }
}
